package com.itasura.factorykit;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author sailor wang
 * @date 2018/11/21 2:34 PM
 * @description
 */

public interface WeaponFactory {

    Weapon create(WeaponType weaponType);

    static WeaponFactory factory(Consumer<Builder> consumer) {
        Map<WeaponType, Supplier<Weapon>> map = new HashMap<>();
        consumer.accept(map::put);
        WeaponFactory factory = name -> map.get(name).get();
        return factory;
    }
}